package jn.cdz.rabbit.mq.sender;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;

import java.util.Date;

/**
 * 轮询消息发送器，所有绑定在此队列上的接收者会轮询获得消息
 */
@Configuration
public class PollingSender {
    @Autowired
    private AmqpTemplate rabbitTemplate;

    public void send(Object data) {
        String context = "hello " + new Date();
        System.out.println("Sender : " + context);
        this.rabbitTemplate.convertAndSend("hello", context);
    }
}
